package com.ljc.dao;

import com.ljc.entity.Attachment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface AttachmentDao {

    void add(List<Attachment> attachments);

    @Select("select * from attachment where type=#{type} and main_id=#{mainId}")
    List<Attachment> getByTypeAndMainId(@Param("type") int type,@Param("mainId") int mainId);

    @Delete("delete from attachment where type=1 and main_id=#{projectPlanningId}")
    void deleteByProjectPlanningId(int projectPlanningId);

    @Delete("delete from attachment where type=2 and main_id=#{contractId}")
    void deleteByContractId(int contractId);
}
